In [1]:
import re
from glob import glob
import inspect
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
from bokeh.io import output_notebook
from bokeh.plotting import show
output_notebook()
from electroninserts import (
parameterise_single_insert, display_parameterisation,
convert2_ratio_perim_area, interactive, fallback_scatter,
spline_model_with_deformability)
In [2]:
# !pip install --upgrade version_information
# %load_ext version_information
# %version_information electroninserts, re, numpy, pandas, matplotlib, bokeh, version_information
Out[2]:
In [3]:
energy = 6
applicator = 10
ssd = 100
x = [0.99, -0.14, -1.0, -1.73, -2.56, -3.17, -3.49, -3.57, -3.17, -2.52, -1.76,
-1.04, -0.17, 0.77, 1.63, 2.36, 2.79, 2.91, 3.04, 3.22, 3.34, 3.37, 3.08, 2.54,
1.88, 1.02, 0.99]
y = [5.05, 4.98, 4.42, 3.24, 1.68, 0.6, -0.64, -1.48, -2.38, -3.77, -4.81,
-5.26, -5.51, -5.58, -5.23, -4.64, -3.77, -2.77, -1.68, -0.29, 1.23, 2.68, 3.8,
4.6, 5.01, 5.08, 5.05]
width, length, poi = parameterise_single_insert(x, y)
print("Width = {0:0.2f} cm\nLength = {1:0.2f} cm".format(width, length))
display_parameterisation(x, y, width, length, poi)
In [4]:
data_filelist = glob('*_data.csv')
assert len(data_filelist) <= 1, "There appears to be more than 1 data.csv file, please delete the old version(s)"
assert len(data_filelist) == 1, "I need at least one data file"
data_filename = data_filelist[0]
data = pd.read_csv(data_filename)
In [5]:
reference = (
(data['Energy (MeV)'] == energy) &
(data['Applicator (cm)'] == applicator) &
(data['SSD (cm)'] == ssd)
)
input_dataframe = data[reference]
label = np.array(input_dataframe['Label']).astype(str)
width_data = np.array(
input_dataframe['Width (cm @ 100SSD)']).astype(float)
length_data = np.array(
input_dataframe['Length (cm @ 100SSD)']).astype(float)
factor_data = np.array(
input_dataframe['Insert factor (dose insert / dose open)']).astype(float)
input_dataframe
Out[5]:
In [6]:
number_of_data = len(input_dataframe)
if number_of_data >= 8:
ratio_perim_area_data = convert2_ratio_perim_area(width_data, length_data)
ratio_perim_area = convert2_ratio_perim_area(width, length)
factor = float(spline_model_with_deformability(width, ratio_perim_area,
width_data, ratio_perim_area_data, factor_data))
else:
factor = np.nan
print("Width = {0:0.2f} cm\nLength = {1:0.2f} cm\nFactor = {2:0.4f}".format(
width, length, factor))
In [7]:
if number_of_data >= 8:
ratio_perim_area_data = convert2_ratio_perim_area(width_data, length_data)
figure = interactive(
width_data, length_data, ratio_perim_area_data, factor_data, label)
else:
figure = fallback_scatter(width_data, length_data, factor_data, label)
show(figure)
Out[7]:
Copyright © 2016 Simon Biggs
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.